﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SDCFollowThrough
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            GetRunAsync().Wait();
        }
        async Task GetRunAsync()
        {
            using (var client = new HttpClient())
            {
                string StringResponce;
                client.BaseAddress = new Uri("http://localhost:57975/");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add
                        (new MediaTypeWithQualityHeaderValue("application/json"));

                var response = client.GetAsync("api/Values/").Result;
                if (response.IsSuccessStatusCode)
                {
                    var GetString = await response.Content.ReadAsStringAsync();
                    StringResponce = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(GetString);
                    if (StringResponce != null)
                    {
                        MessageBox.Show(StringResponce);
                    }

                }

            }
        }
    }
}
